package com.example.zsf.presenter;

import com.example.zsf.base.Presenter;
import com.example.zsf.base.ZSFGlobal;
import com.example.zsf.network.Api;
import com.example.zsf.network.RetrofitManager;

import java.util.HashMap;

import retrofit2.Call;

public class AccountPresenter extends Presenter {

    public static <T> Call<T> sendMessage(String phone,String validate, PresenterListener<T> presenterListener) {
        Api api = RetrofitManager.getInstance()
                .setBaseUrl(ZSFGlobal.baseUrl)
                .build(Api.class);
        HashMap<String,String> params = new HashMap<>();
        params.put("phone", phone);
        params.put("validate", validate);
        Call call = api.sendMessage(params);
        call.enqueue(new SampleCallback(presenterListener));
        return call;
    }


    public static <T> Call<T> login(String phone,String code, PresenterListener<T> presenterListener) {
        Api api = RetrofitManager.getInstance()
                .setBaseUrl(ZSFGlobal.baseUrl)
                .build(Api.class);
        HashMap params = new HashMap();
        params.put("phone", phone);
        params.put("code", code);
        Call call = api.login(params);
        call.enqueue(new SampleCallback(presenterListener));
        return call;
    }
}
